/*
 * 
 */
package fr.univtln.superplanning;

import java.io.IOException;
import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;

import fr.univtln.superplanning.api.SuperplanningManagerDB;
import fr.univtln.superplanning.controller.DBLoginController;
import fr.univtln.superplanning.exceptions.NegativeNumberException;
import fr.univtln.superplanning.gui.LookAndFeelManager;

// TODO: Auto-generated Javadoc
/**
 * The Class TestPersistence.
 */
public class SuperplanningGUI {

	/** The Constant logger. */
	private static final Logger logger = Logger.getLogger("superplanning_logger");

	/**
	 * The main method.
	 * 
	 * @param args
	 *            the arguments
	 * @throws NegativeNumberException
	 *             the negative number exception
	 * @throws SecurityException
	 *             the security exception
	 * @throws IOException
	 *             Signals that an I/O exception has occurred.
	 */
	public static void main(String[] args) throws NegativeNumberException, SecurityException,
			IOException {

		// Logger configuration to show FINE and more importants message
		ConsoleHandler consoleHandler = new ConsoleHandler();
		// %g for add a number to the filename
		// 1000 000 : 100ko / file
		// 3 file maximum
		// => file rotation.
		Handler fileHandler = new FileHandler("Superplanning%g.log", 100000, 1, true);
		logger.addHandler(consoleHandler);
		logger.addHandler(fileHandler);
		logger.setLevel(Level.ALL);
		consoleHandler.setLevel(Level.ALL);
		// //

		logger.info("Starting application.");

		LookAndFeelManager.loadSystemLookAndFeel();

		// some default values.

		// POWER OF OO ABSTRACTION : if we want to change the DAO method, we
		// only have to change SuperplanningManagerDB by
		// SuperoplanningManagerXML (for example).
		DBLoginController dbLoginController = new DBLoginController(new SuperplanningManagerDB());

		dbLoginController.getDbLogin().setProtocole("postgresql");
		dbLoginController.getDbLogin().setDatabaseName("Superplanning");
		dbLoginController.getDbLogin().setHost("localhost");
		dbLoginController.getDbLogin().setPort(5432);

		// love mvc for this ;>
		dbLoginController.getDbLogin().fireUpdate();

		dbLoginController.showView();
	}
}
